/*
 * TraceValueScope.h
 *
 *  Created on: 2012/08/06
 *      Author: guanxiaoying
 */

#ifndef TRACEVALUESCOPE_H_
#define TRACEVALUESCOPE_H_
#define SCOPEKIND_IN 1	/* min ~ max */
#define SCOPEKIND_OUT 2  /* typemin ~ min or max ~ typemax */
#define SCOPEKIND_NAN 3  /* invalid, but has value */
#define SCOPEKIND_VOID 0 /* has no value */

#define CALERROR_DIVIDE_ZERO  1
#define CALERROR_OVERFLOW 2
#define CALERROR_FLOAT_OVERFLOW 3


#define VARI_CHANGED  0x1000
#define FUNCTION_CHANGED  0x2000

#define VARI_CHANGED_BY_ASSIGN   (VARI_CHANGED+1)
#define VARI_CHANGED_BY_RELATION (VARI_CHANGED+2)
#define VARI_CHANGED_BY_MERGE    (VARI_CHANGED+3)
#define VARI_CHANGED_BY_ADDR_RESTORE    (VARI_CHANGED+4)
#define VARI_CHANGED_BY_INLOOP_RESTORE     (VARI_CHANGED+5)

#define FUNCTION_CHANGED_BY_RET   (FUNCTION_CHANGED+1)
#define FUNCTION_CHANGED_BY_MERGE  (FUNCTION_CHANGED+2)

VOID Tr_ScpGetScpByType( AST astLinkType, TRVALUESCP * pstVarScope );
VOID Tr_ScpGetOperandValue( AST astCmdList, TRVALUESCP *pstVarScope );
VOID Tr_ScpGetCmdValue( AST astCmdList, TRVALUESCP *pstVarScope );
VOID Tr_ScpGetCmdValue( AST astCmdList, TRVALUESCP *pstVarScope );
VOID Tr_ScpMergeAndAnd( TRVALUESCP *stLeft, TRVALUESCP *stRight, TRVALUESCP *stResult );
VOID Tr_ScpMergeOrOr( TRVALUESCP *stLeft, TRVALUESCP *stRight, TRVALUESCP *stResult );
VOID Tr_ScpGetScpByType( AST astLinkType, TRVALUESCP * pstVarScope );
BOOL Tr_ScpHasValue(  TRVALUESCP * pstVarScope );
VOID Tr_ScpIncrement( TRVALUESCP *stLeft, TRVALUESCP *stResult );
VOID Tr_ScpDecrement( TRVALUESCP *stLeft, TRVALUESCP *stResult );
VOID Tr_ScpSetInvalid( TRVALUESCP *stResult );
VOID Tr_ScpGetMinMaxByBytes( TRVALUESCP *pstVarScope, U2 size, BOOL bSigned, BOOL bFloating );
VOID Tr_ScpGetMinMaxByBits( TRVALUESCP *pstVarScope, U2 size, BOOL bSigned );
VOID Tr_ScpGetScpByType( AST astLinkType, TRVALUESCP * pstVarScope );
VOID Tr_ScpArithPromotionFlags( TRVALUESCP *stLeft, TRVALUESCP *stRight, TRVALUESCP *stResult );
VOID Tr_ScpLimitedByRelation( AST  astCmdList  );
VOID Tr_ScpLimitScopeByGreater( TRVALUESCP *variScope, TRVALUESCP *pVarScope, TRVALUESCP *pstVarScope, BOOL bEqual );
VOID Tr_ScpLimitScopeByLess( TRVALUESCP *variScope, TRVALUESCP *pVarScope, TRVALUESCP *pstVarScope, BOOL bEqual );
VOID Tr_ScpAdjustType( TRVALUESCP *scp, AST type );
#endif /* TRACEVALUESCOPE_H_ */
